package com.china08.yxyapi.util;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.amqp.rabbit.core.RabbitTemplate;

import com.china08.yxyapi.config.RabbitConfig;

public class RabbitMqSendUtil {

    /**
     * 学校网站-修改PV
     * 
     * @param schoolId
     */
    public static void schoolWebsitPvUpd(String schoolId) {
        SpringContextUtil.getBean(RabbitTemplate.class).convertAndSend(RabbitConfig.YW_SCHOOL_WEBSITE_PV, schoolId);
    }

    /**
     * 继续教育,用户任务状态修改
     * 
     */
    public static void userTaskUpd(Map<String, Object> map) {
        SpringContextUtil.getBean(RabbitTemplate.class).convertAndSend(RabbitConfig.YW_CONTINUEDU_USER_TASK_TWO, map);
    }

    /**
     * 继续教育,报名人数统计
     * 
     * @param taskId
     * @param schoolId
     */
    public static void enrolStatis(Map<String, Object> map) {
        SpringContextUtil.getBean(RabbitTemplate.class).convertAndSend(RabbitConfig.YW_CONTINUEDU_ENROL_ONE, map);
    }

    /**
     * 继续教育,完成任务统计
     * 
     * @param taskId
     * @param schoolId
     */
    public static void finishTaskStatis(Map<String, Object> map) {
        SpringContextUtil.getBean(RabbitTemplate.class).convertAndSend(RabbitConfig.YW_CONTINUEDU_FINISH_TASK, map);
    }

    /**
     * 备授课系统,备课包pv统计 发送数据到rabbitMq队列
     * 
     * @param classId
     * @param studentId
     * @param taskId
     */
    public static void lecturePvStatis(String prePackId) {
        SpringContextUtil.getBean(RabbitTemplate.class).convertAndSend(RabbitConfig.YW_LECTURE_PREPACK_PV, prePackId);
    }

    /**
     * 备授课系统,备课包使用采纳率 发送数据到rabbitMq队列
     * 
     * @param prePackId
     */
    public static void lectureUsedStatis(String prePackId) {
        SpringContextUtil.getBean(RabbitTemplate.class).convertAndSend(RabbitConfig.YW_LECTURE_PREPACK_USED_COUNT,
                prePackId);
    }

    /**
     * 备授课系统,备授课使用采纳率,接收参数为 备授课包id数组
     * 
     * @param prePackIds
     */
    public static void lectureUsedStatis(String[] prePackIds) {
        if (prePackIds != null && prePackIds.length > 0) {
            for (String prePackId : prePackIds) {
                SpringContextUtil.getBean(RabbitTemplate.class)
                        .convertAndSend(RabbitConfig.YW_LECTURE_PREPACK_USED_COUNT, prePackId);
            }
        }

    }

    /**
     * 教师考勤统计, 将需要统计考勤的学校id 放入到rabbitMQ中
     * 
     * @param schoolIds
     */
    public static void attendanceStatistics(List<String> schoolIds, Integer day) {
        if (schoolIds != null && schoolIds.size() > 0) {
            Map<String, Integer> schoolAndDay;
            for (String schoolId : schoolIds) {
                schoolAndDay = new HashMap<String, Integer>();
                schoolAndDay.put(schoolId, day);
                SpringContextUtil.getBean(RabbitTemplate.class)
                        .convertAndSend(RabbitConfig.YW_TEA_ATTENDANCE_STATISTICS, schoolId + "_" + day);
            }
        }
    }

    /**
     * 学生考勤记录统计 未签到的学生去创建记录数据
     * 
     * @param schoolIds
     * @param day
     */
    public static void attendanceStatisticsForStudent(List<String> schoolIds, Integer day) {
        if (schoolIds != null && schoolIds.size() > 0) {
            Map<String, Integer> schoolAndDay;
            for (String schoolId : schoolIds) {
                schoolAndDay = new HashMap<String, Integer>();
                schoolAndDay.put(schoolId, day);
                SpringContextUtil.getBean(RabbitTemplate.class)
                        .convertAndSend(RabbitConfig.YW_STU_ATTENDANCE_STATISTICS, schoolAndDay);
            }
        }
    }

    public static void userResourceStatisticsForMonth(List<Map<String, String>> lMaps) {
        if (lMaps != null && !lMaps.isEmpty()) {

        }
    }

    public static void ywStatisticsResourceArea(Integer day) {
        SpringContextUtil.getBean(RabbitTemplate.class).convertAndSend(RabbitConfig.YW_STATISTICS_RESOURCE_AREA, day);
    }

    public static void ywStatisticsResourceSchool(Integer day) {
        SpringContextUtil.getBean(RabbitTemplate.class).convertAndSend(RabbitConfig.YW_STATISTICS_RESOURCE_SCHOOL, day);
    }

    public static void ywStatisticsResourceMonth(Integer monthAndYear) {
        SpringContextUtil.getBean(RabbitTemplate.class).convertAndSend(RabbitConfig.YW_USER_RESOURCE_STATISTICS_MONTH,
                monthAndYear);
    }

    /**
     * 学校资源,按照日期进行统计
     */
    public static void ywStatisticsResourceSchoolDay(Integer day) {
        SpringContextUtil.getBean(RabbitTemplate.class).convertAndSend(RabbitConfig.YW_STATISTICS_RESOURCE_SCHOOL_DAY,
                day);
    }

    /**
     * 学校资源,按照日期进行统计
     */
    public static void huixuePlanCheckDay(Integer day) {
        SpringContextUtil.getBean(RabbitTemplate.class).convertAndSend(RabbitConfig.YW_HUIXUE_PLAN_CHECK_DAY, day);
    }

    // ------------------------新添----------------------------//
    /**
     * 查询学校总共的资源数据
     * 
     * @param day
     */
    public static void ywStatisticsResourceSchoolEs(Integer day) {
        SpringContextUtil.getBean(RabbitTemplate.class).convertAndSend(RabbitConfig.YW_STATISTICS_RESOURCE_SCHOOL_ES,
                day);
    }

    /**
     * 查询用户总共的资源数据
     * 
     * @param day
     */
    public static void ywStatisticsResourceUserSchoolEs(Integer day) {
        SpringContextUtil.getBean(RabbitTemplate.class)
                .convertAndSend(RabbitConfig.YW_STATISTICS_RESOURCE_SCHOOL_USER_ES, day);
    }

    /**
     * 查询用户对应的资源和微课数据（每天）
     * 
     * @param formatDate4
     */
    public static void ywStatisticsResourceUserSchoolDayEs(Integer day) {
        SpringContextUtil.getBean(RabbitTemplate.class)
                .convertAndSend(RabbitConfig.YW_STATISTICS_RESOURCE_SCHOOL_USER_DAY_ES, day);
    }

    /**
     * 查询学校资源数据（每天）
     * 
     * @param day
     */
    public static void ywStatisticsResourceSchoolDayEs(Integer day) {
        SpringContextUtil.getBean(RabbitTemplate.class)
                .convertAndSend(RabbitConfig.YW_STATISTICS_RESOURCE_SCHOOL_DAY_ES, day);
    }

    /**
     * 用户角色信息es保存
     * 
     * @param uid
     */
    public static void esUserInfoSave(String uid) {
        SpringContextUtil.getBean(RabbitTemplate.class).convertAndSend(RabbitConfig.ES_USER_ROLEINFO_SAVE, uid);
    }

    /******************************************** 新修改 **************************************************/

    /**
     * 查询学校总共的资源数据
     * 
     * @param day
     */
    public static void ywStatisticsResourceSchoolNewEs(Integer day) {
        SpringContextUtil.getBean(RabbitTemplate.class)
                .convertAndSend(RabbitConfig.YW_STATISTICS_RESOURCE_SCHOOL_NEW_ES, day);

    }

    /**
     * 统计学日的资源数据（包括周，月）
     * 
     * @param day
     */
    public static void ywStatisticsResourceUserSchoolDayNewEs(Integer day) {
        SpringContextUtil.getBean(RabbitTemplate.class)
                .convertAndSend(RabbitConfig.YW_STATISTICS_RESOURCE_SCHOOL_USER_DAY_NEW_ES, day);
    }

    public static void ywStatisticsResourceSchoolDayNewEs(Integer day) {
        SpringContextUtil.getBean(RabbitTemplate.class)
                .convertAndSend(RabbitConfig.YW_STATISTICS_RESOURCE_SCHOOL_DAY_NEW_ES, day);

    }
}
